<script src='<?php echo DIR_JS?>ui.datepicker.js' type='text/javascript' language='javascript'> </script>
<div class="section" id="sitemaplist">
<form name="frm" action="<?php echo $action?>" method="post" enctype="multipart/form-data">
	<div id="product_panel">
		<div class="section-title">
			PRODUCT INFORMATION   
			<div class="button right">
				<input type="submit" name="submitproduct" value="<?php echo $this->document->text['button_save']?>" class="button"/>
				<input type="button" value="<?php echo $this->document->text['button_cancel']?>" class="button" onclick="linkto('<?php echo $cancel?>')"/>   
				<input type="hidden" name="stockid" value="<?php echo $stock['stockid']?>" />   
			</div>
			<div class="clearer">^&nbsp;</div>
		</div>
		<div class="section-content padding1">
			<table><tr>
			<td width="80%" valign="top">
				<p>
					<label>Product Group</label> : <select name="groupid" style="width:60%"><?php echo $cb_productgroup?></select>
					<a id="quickaddgroup" class="button"><?php echo $this->document->text['button_quickadd']?></a>
				</p>
				<p>
					<label>Product name</label> : <input type="text" name="productname" value="<?php echo $product['productname']?>" class="text" style="width:80%" /><i class="error"><?php echo $error['productname']?></i>
				</p>
					
				<p>
					<label><?php echo $this->document->text['text_barcode']?></label> : <input type="text" id="barcode" name="barcode" value="<?php echo $product['barcode']?>" class="text"  style="width:50%" /> <input type="hidden" name="oldbarcode" value="<?php echo $product['barcode']?>"  />
					<a class="generate" href="#">Auto generate</a>
					<i class="error"><?php echo $error['barcode']?></i>
				</p>
				
				<!--<p>
					<label>Product ID</label> : <input type="text" name="productid" value="<?php echo $product['productid']?>" class="text" size="30" />
					<span class="right"><label><?php echo $this->document->text['text_barcode']?></label> : <input type="text" name="barcode" value="<?php echo $product['barcode']?>" class="text" size="30" /></span>
					<div class="clearer">&nbsp;</div>	 
				</p>--> 
				
				<p>
					<label><?php echo $this->document->text['text_description']?>:</label> : <textarea name="description" cols="100"  style="width:80%"><?php echo $product['description']?></textarea>
				</p>
				<p>
					<label>Purchase Cost (Input Cost)</label> : <input type="text" name="netprice" value="<?php echo $product['netprice']?>" class="text"  style="width:27%" />
					<span class="right" style="width:50%"><label><?php echo $this->document->text['text_sallingprice']?> (<?php echo $this->document->text['text_outputprice']?>)</label> : <input type="text" name="saleprice" value="<?php echo $product['saleprice']?>" class="text" style="width:60%" /></span>
					<div class="clearer">&nbsp;</div>	 
				</p>
				<p>
					<label>Unit </label> : <select name="unit" style="width:27%"><?php echo $cb_unit?></select>
					<span class="right" style="width:50%"><label>Minimum Alert</label> : <input type="text" name="notifyqty" value="<?php echo $product['notifyqty']?>" class="text" style="width:60%" /></span>
					<div class="clearer">&nbsp;</div>	 
				</p>	
			</td>
			<td valign="top" style="vertical-align:top">
				<p id="pnImage">
					<label for="image">Image</label><br /><br />
					<a id="btnAddImage" class="button">Browse</a>&nbsp;&nbsp;<a id="btnRemoveImage" class="button">Remove</a><br />
					<div style="width:200px; height:200px; border:1px solid #666666">
						<img id="preview" src="<?php echo $imagethumbnail?>" />
					</div>
					<input type="hidden" id="imagepath" name="imagepath" value="<?php echo $imagepath?>" />
					<input type="hidden" id="imageid" name="imageid" value="<?php echo $imageid?>" />
					<input type="hidden" id="imagethumbnail" name="imagethumbnail" value="<?php echo $imagethumbnail?>" />
				</p>
				
				
				<div id="errorupload" class="error" style="display:none"></div>
				
				<div class="loadingimage" style="display:none"></div>
			</td>
			</tr></table>
			
		</div>
	</div>
	<div id="group_panel" style="display:none">
		<div class="section-title">
			QUICK ADD PRODUCT GROUP   
			<div class="button right">
				<input type="submit" name="submitgroup" value="Save Group" class="button"/>
				<input id="btnGroupCancel" type="button" value="<?php echo $this->document->text['button_cancel']?>" class="button" />   
				<input type="hidden" id="quick_groupid" name="quick_groupid" value="<?php echo $group['groupid']?>" />   
			</div>
			<div class="clearer">^&nbsp;</div>
		</div>

		<div class="section-content padding1">
			<div>
				<p>
					<label><?php echo $this->document->text['text_groupname']?></label> : <input type="text" id="quick_groupname" name="quick_groupname" value="<?php echo $group['groupname']?>" class="text" size=60 />
					<i class="error_quick_groupname"><?php echo $error['quick_groupname']?></i>
				</p>
				<p>
					<label>Brand </label> : 
					<select id="quick_brandid" name="quick_brandid">
						<?php echo $cbxbrand?>
					</select>
				</p>
			 </div>
		</div>
	</div>
</form>    
</div>


<script src='<?php echo DIR_JS?>ajaxupload.js' type='text/javascript' language='javascript'> </script>
<script src="<?php echo DIR_JS?>jquery.tabs.pack.js" type="text/javascript"></script>

<script type="text/javascript" charset="utf-8">
var DIR_UPLOADPHOTO = "<?php echo $DIR_UPLOADPHOTO?>";
var formtype = "<?php echo $formtype?>";
$(document).ready(function() { 

	$("#btnRemoveImage").click(function(){
		$("#preview").attr("src","");
		$("#imagepath").val("");
		$("#imageid").val("");
		$("#imagethumbnail").val("");
	});
	$("#quickaddgroup").click(function(){
		$("#product_panel").hide();
		$("#group_panel").show();
	});
	$("#btnGroupCancel").click(function(){
		$("#quick_groupname").val("");
		$(".error_quick_groupname").html("");
		$("#product_panel").show();
		$("#group_panel").hide();
	});
	
	if(formtype == 1)
	{
		$("#product_panel").show();
		$("#group_panel").hide();
	}
	else
	{
		$("#product_panel").hide();
		$("#group_panel").show();
	}
	
	$(".error").each(function(){
		if($(this).html() == "")
		{
			$(this).hide();
		}
		else
		{
			$(this).show();
		}
	});
	
	$(".generate").click(function(){
		$.post("?route=category/product/newbarcode", 
				$("#formlist").serialize(), 
				function(data)
				{
					if(data!="")
					{
						$("#barcode").val(data);
					}
				}
		);
	});
});
</script>

<script src="<?php echo DIR_JS?>uploadpreview.js" type="text/javascript"></script>

